package com.example.campsystem.controller;

import com.example.campsystem.entity.CampImages;
import com.example.campsystem.entity.CustomApi;
import com.example.campsystem.entity.Camps;
import com.example.campsystem.service.CampImagesService;
import com.example.campsystem.service.CampsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CampController {
    @Autowired
    private CampsService campsService;
    @Autowired
    private CampImagesService campImagesService;
    @GetMapping("/camplist")
    public ResponseEntity<CustomApi> getCampList(@RequestParam(required = false) Integer cityId,
                                                 @RequestParam(required = false) Integer categoryId,
                                                 @RequestParam(required = false) String name) {
        List<Camps> campList = campsService.getCampList(cityId, categoryId, name);
        CustomApi customApi = new CustomApi();
        customApi.setCode(200);
        customApi.setMsg("success");
        customApi.setData(campList);
        return new ResponseEntity<>(customApi, HttpStatus.OK);
    }
    @GetMapping("/camp/banner")
    public ResponseEntity<CustomApi> getCampimage(){
        List<CampImages> campImages = campImagesService.list();
        CustomApi customApi = new CustomApi();
        customApi.setCode(200);
        customApi.setMsg("success");
        customApi.setData(campImages);
        return new ResponseEntity<>(customApi, HttpStatus.OK);
    }

}
